<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@page import="dataBase.Business"%>
<%@page import="controller.Controller"%>
<%@page import="dataBase.Order"%>
<%@page import="dataBase.Status"%>
<%@page import="com.google.appengine.api.datastore.Key"%>
<%@page import="java.util.List"%>
<%@ page contentType="text/html; charset=utf-8" %>
<%@page import="language.Hebrew"%>
<%@page import="language.LangFactory"%>
<%@page import="language.LangIntrf"%>
<%
	LangFactory langFactory= new LangFactory();
	String langName = request.getParameter("lang");

	LangIntrf lang =null;
	if(langName!=null){
		lang = langFactory.getLang(request.getParameter("lang"));
		session.setAttribute("lang",langName);
	}
	else
		lang = langFactory.getLang((String)session.getAttribute("lang"));
	String langSign = lang.getLang();
	
	
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="js/jquery-1.6.1.min.js"></script>
<script type="text/javascript" src="js/jquery.easing.1.3.js"></script>
<script type="text/javascript" src="js/jquery.zaccordion.min.js"></script>
<link href="showOrder.css" rel="stylesheet" type="text/css" />

<%
	String orderNum = request.getParameter("orderNum");
	String bizName = request.getParameter("bizName");
	String phone = request.getParameter("phone");
	
	Controller controller = Controller.getInstance();
	boolean orderExist=false;
	int statusIndex = 0;
	int width =0 ;
	String currentStatus = "";
	List<String> statusList = null;
	Order order = null;
	if(orderNum!=null && bizName!=null && phone!=null&& !orderNum.equals("") && !bizName.equals("")&& !phone.equals("")){
		phone = phone.replace("-","");
		System.out.println("*********************************");
		System.out.println(bizName);
		//statusList = controller.getStatusesOfBiz(bizName);
		System.out.println("asd "+orderNum);
		order = controller.getOrder(Integer.parseInt(orderNum),bizName);
		
		if(order!=null){
			orderExist=true;
			statusList = order.getStatusNamesList();
			currentStatus = controller.getCurrentStatusOfOrder(order);
			for(String s : statusList){
				if(s.equals(currentStatus))
					break;
				statusIndex++;
			}
			width = 200+40*(statusList.size()-1);
		}
	}
	if(orderExist && !order.getPhoneNumber().getNumber().equals(phone))
		orderExist=false;
%>
<style type="text/css">
#my {
	width: <%=width%>px; 
}
</style>
<script type="text/javascript">
	$(document).ready(function() {
		$("#example1").zAccordion({
			timeout: 2000,
			slideWidth: 200,
			width: <%=width%>,
			height: 120,
			auto: false,
			startingSlide: <%=statusIndex%>, 
			trigger: "mouseover",
			animationComplete: function () {
				if($(this).index()<<%=statusIndex%>){
					$("#example1").delay(5000).zAccordion("trigger", <%=statusIndex+1%>);
				}
				else{
					$("#example1").delay(5000).zAccordion("trigger", <%=statusIndex%>);
				}
			}
		});
	});
	
</script>
</head>

<body style="text-align: <%=lang.getAlign()%>;" dir="<%=lang.getDirection()%>">
<%if(orderExist){ %>
<div id="my">
			<ul id="example1">
			<%
				for(int i=0;i<statusIndex;i++){
			%>
				<li class="over">
					<div class="statusContent"><%=statusList.get(i) %></div>
                    <div class="v" style="color:#0F3;!important"><img src="images/v.png" width="30" height="30"/> <p>Done!</p></div>
				</li>
			<%  }
				
			%>
				<li class="current">
					<div class="statusContent"><%=currentStatus %></div>
					<div class="v"><img src="images/wait.png" width="30" height="30"/><p>Pending</p></div>
				</li>
			<%
				for(int i=statusIndex+1;i<statusList.size();i++){
			%>
				<li class="next">
					<div class="statusContent"><%=statusList.get(i) %></div>
					<div class="v"><img src="images/next.png" width="30" height="30"/><p>Next</p></div>
				</li>
			<%  }
			%>
				
           
			</ul>
			</div>
			<%}
else{
%>
<b><%=lang.getSORRY_LABEL() %></b><br/><br/>
<%} %>
<%if(lang.getDirection().equals("ltr")){ %>
			 <%=lang.getPOWERED_BY_LABEL() %><a href="<%=Controller.getInstance().getSyncaWebAddress()%>" target="#"><img src="images/logo2.png" alt=""  height="24" style="margin-left: 10px;margin-right: 10px; margin-top: 5px;"/></a><br />
<%}else{ %>		
			 <a href="<%=Controller.getInstance().getSyncaWebAddress()%>" target="#"><img src="images/logo2.png" alt=""  height="24" style="margin-left: 10px;margin-right: 10px; margin-top: 5px;"/></a><%=lang.getPOWERED_BY_LABEL() %><br />
<%} %>	 
			 <a href="orderForm.jsp?bizName=<%=bizName%>"><%=lang.getFIND_ANOTHER_LABEL() %></a>
</body>
</html>
